
 
package com.junitUtil.spring;	
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.TypeConverter;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.support.BeanDefinitionValidationException;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.support.RootBeanDefinition;

import java.util.Set;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;



/**
 * 1.自定义beanFactory 依赖检查不抛异常 
 * 2.静态 （保证aop的部分代码里能取到当前单测环境下的beanfactory）
 * 
 **/

public class DecoratorBeanFactory  extends DefaultListableBeanFactory {
    private final static DecoratorBeanFactory INSTANCE = new DecoratorBeanFactory();
    public static String JUNIT_TEST_NAME="JUNIT_TEST_NAME";

    public static DecoratorBeanFactory getInstance(){
        return INSTANCE;
    }
    private DecoratorBeanFactory() {
      super();
    }
    
 
    @Override
    public Object resolveDependency(DependencyDescriptor descriptor, String beanName, Set<String> autowiredBeanNames, TypeConverter typeConverter) {
        try {
            return super.resolveDependency(descriptor, beanName, autowiredBeanNames, typeConverter);
        } catch (NoSuchBeanDefinitionException var8) {
            return null;
        }
    }
    
    
}
